package com.ky.my.controller;




import cn.hutool.core.convert.NumberWithFormat;
import com.ky.my.Message;
import com.ky.my.service.MessageService;
import com.ky.common.config.SystemConfig;
import com.ky.common.util.JwtUtil;

import com.ky.common.vo.R;

import com.ky.common.vo.R;
import com.ky.my.service.MessageService;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hmt
 * @since 2024-06-17
 */
@CrossOrigin
@RestController
@RequestMapping("/message")
public class MessageController {
    @Autowired
    private MessageService messageService;
    @RequestMapping("/findAllMassage")

    public R findAllMassage(Message message) {


        return messageService.findAllMassage( message);
    }
    @RequestMapping("/sendMassage")
    public R sendMassage(HttpServletRequest request, @RequestBody Message message) {
//        // 配置userid
//        String token = request.getHeader(SystemConfig.HEADER_TOKEN);
//
//        Integer id = ((NumberWithFormat) JwtUtil.parseToken(token, "id")).intValue();
//        message.setUserId(id);



        return messageService.findAllMassage(message);
    }
}

